// ThreadPool.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "task.h"
#include "ThreadManage.h"
#include "UntilHelpers.h"
#include <Windows.h>

using namespace std;
int g_i = 0;
class mytask : public ITask
{
public:
	void run()
	{
		int id = GetCurrentThreadId();
		printf(" %d doing now... %d\n", id, g_i++);
		Sleep(100);
	}
};

int _tmain(int argc, _TCHAR* argv[])
{
	ThreadManage<ITask*, helpers::Lock<CRITICAL_SECTION> > t;
	//auto ptrtm = ThreadManage<ITask*, helpers::Lock<CRITICAL_SECTION> >::instance();
	t.initialize(5);
	for (int i = 0; i < 50; ++i)
	{
		t.add_task(new mytask());
	}
	t.shutdown();
	system("pause");
	return 0;
}

